home *** CD-ROM | disk | FTP | other *** search
/ Transformers: Revenge of …he Game: Press Kit (USA) / Transformers - Revenge of the Fallen - The Game - Press Kit (USA).bin / Transformers.swf / scripts / fl / video / FPADManager.as < prev    next >
Text File  |  2009-06-19  |  4KB  |  107 lines

  1. package fl.video
  2. {
  3.    import flash.events.Event;
  4.    import flash.events.IOErrorEvent;
  5.    import flash.events.SecurityErrorEvent;
  6.    import flash.net.URLLoader;
  7.    import flash.net.URLRequest;
  8.    
  9.    public class FPADManager
  10.    {
  11.       
  12.       public static const VERSION:String = "2.1.0.19";
  13.       
  14.       public static const SHORT_VERSION:String = "2.1";
  15.        
  16.       
  17.       flvplayback_internal var _uriParam:String;
  18.       
  19.       flvplayback_internal var _parseResults:ParseResults;
  20.       
  21.       private var _owner:INCManager;
  22.       
  23.       flvplayback_internal var rtmpURL:String;
  24.       
  25.       flvplayback_internal var _url:String;
  26.       
  27.       flvplayback_internal var xmlLoader:URLLoader;
  28.       
  29.       flvplayback_internal var xml:XML;
  30.       
  31.       public function FPADManager(param1:INCManager)
  32.       {
  33.          super();
  34.          _owner = param1;
  35.       }
  36.       
  37.       flvplayback_internal function connectXML(param1:String, param2:String, param3:String, param4:ParseResults) : Boolean
  38.       {
  39.          _uriParam = param2;
  40.          _parseResults = param4;
  41.          _url = param1 + "uri=" + flvplayback_internal::_parseResults.protocol;
  42.          if(flvplayback_internal::_parseResults.serverName != null)
  43.          {
  44.             _url += "/" + flvplayback_internal::_parseResults.serverName;
  45.          }
  46.          if(flvplayback_internal::_parseResults.portNumber != null)
  47.          {
  48.             _url += ":" + flvplayback_internal::_parseResults.portNumber;
  49.          }
  50.          if(flvplayback_internal::_parseResults.wrappedURL != null)
  51.          {
  52.             _url += "/?" + flvplayback_internal::_parseResults.wrappedURL;
  53.          }
  54.          _url += "/" + flvplayback_internal::_parseResults.appName;
  55.          _url += param3;
  56.          xml = new XML();
  57.          xmlLoader = new URLLoader();
  58.          flvplayback_internal::xmlLoader.addEventListener(Event.COMPLETE,flvplayback_internal::xmlLoadEventHandler);
  59.          flvplayback_internal::xmlLoader.addEventListener(IOErrorEvent.IO_ERROR,flvplayback_internal::xmlLoadEventHandler);
  60.          flvplayback_internal::xmlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,flvplayback_internal::xmlLoadEventHandler);
  61.          flvplayback_internal::xmlLoader.load(new URLRequest(flvplayback_internal::_url));
  62.          return false;
  63.       }
  64.       
  65.       flvplayback_internal function xmlLoadEventHandler(param1:Event) : void
  66.       {
  67.          var proxy:String = null;
  68.          var e:Event = param1;
  69.          try
  70.          {
  71.             if(e.type != Event.COMPLETE)
  72.             {
  73.                _owner.helperDone(this,false);
  74.             }
  75.             else
  76.             {
  77.                xml = new XML(flvplayback_internal::xmlLoader.data);
  78.                if(flvplayback_internal::xml == null || flvplayback_internal::xml.localName() == null)
  79.                {
  80.                   throw new VideoError(VideoError.INVALID_XML,"URL: \"" + flvplayback_internal::_url + "\" No root node found; if url is for an flv it must have .flv extension and take no parameters");
  81.                }
  82.                if(flvplayback_internal::xml.localName() != "fpad")
  83.                {
  84.                   throw new VideoError(VideoError.INVALID_XML,"URL: \"" + flvplayback_internal::_url + "\" Root node not fpad");
  85.                }
  86.                proxy = null;
  87.                if(flvplayback_internal::xml.proxy.length() > 0 && flvplayback_internal::xml.proxy.hasSimpleContent() && flvplayback_internal::xml.proxy.*[0].nodeKind() == "text")
  88.                {
  89.                   proxy = flvplayback_internal::xml.proxy.*[0].toString();
  90.                }
  91.                if(proxy == null)
  92.                {
  93.                   throw new VideoError(VideoError.INVALID_XML,"URL: \"" + flvplayback_internal::_url + "\" fpad xml requires proxy tag.");
  94.                }
  95.                rtmpURL = flvplayback_internal::_parseResults.protocol + "/" + proxy + "/?" + flvplayback_internal::_uriParam;
  96.                _owner.helperDone(this,true);
  97.             }
  98.          }
  99.          catch(err:Error)
  100.          {
  101.             _owner.helperDone(this,false);
  102.             throw err;
  103.          }
  104.       }
  105.    }
  106. }
  107.